package com.gg.user.gguser.controller;

import com.gg.user.gguser.service.GgFileService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestPart;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

import java.io.IOException;

/**
 * @author yangxinlei
 * @date 2020/4/18
 */
@RestController
public class GgFileController {

    @Autowired
    private GgFileService ggFileService;

    @PostMapping(value = "/uploadFile", consumes = MediaType.MULTIPART_FORM_DATA_VALUE)
    public Object handleFileUpload(@RequestPart(value = "file") MultipartFile file) throws Exception {
        return ggFileService.upload(file.getOriginalFilename(), file.getBytes());
    }
}
